﻿Imports ADOEntity
Imports System.Data
Partial Class Administrator_mSanctionList
    Inherits Web.UI.BasePage
    Private Const PathFileFloderBatch As String = "KYC_Sanction_list\Santion_List_Batch\"
    Private Const PathFileFloderBatchTest As String = "KYC_Sanction_list\Santion_List_BatchTest\"
    'Private Const FileType As String = ".csv"
    Private Const FileType As String = ""
    Dim SanctionEntity As SanctionEntities
    Dim dsSanction As New DataSet
    Dim clsQuery As clsDatabase
    Dim clsDataTable As New clsLINQToDataTable
    Dim intBeforeItemIndex As Integer
    Dim clsSessionMenuRight As clsSessionMenuRight = New clsSessionMenuRight
    Dim strMsg As String = ""

#Region " Even Page "

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    
        btnSearch.Text = Resources.resButton.btnSearch
        btnAdd.Text = Resources.resButton.btnAdd
        btnModify.Text = Resources.resButton.btnModify
        btnDelete.Text = Resources.resButton.btnDelete
        btnClear.Text = Resources.resButton.btnClear
        btnPrint.Text = Resources.resButton.btnPrint

        lblMsg.Text = Resources.resMessageAlert.alertEmptyGrid
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            chkIsLogin()
            clsSessionMenuRight = Session("clsMenuRight")

            If (Not IsPostBack) Then
                CreateControlMP()
                setButton(1)
                ddlList.SelectedValue = "0"
                IsDataBind()
            Else
                dsSanction = Session("dsTblMaster")
                gvSanctionList.DataSource = dsSanction.Tables("mSanctionList")
                gvSanctionList.DataBind()

            End If
            trhide.Visible = False
        Catch ex As Exception

        End Try

    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        Session("dsTblMaster") = dsSanction
    End Sub

#End Region

#Region "SetForm"

    Sub CreateControlMP()

        Dim lblForm As Label = CType(Master.FindControl("lblForm"), Label)
        lblForm.Text = "ข้อมูลหลัก > KYC > ประเภท list ความเสี่ยง"
    End Sub

#End Region


#Region " Even Button "


    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        IsDataBind()
        clearGvIndex()
        SaveLog(1)
    End Sub

    Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        ' Response.Redirect("Department.aspx?Status=Add")

        Try
            If chkBeforeSave() Then
                SanctionEntity = New SanctionEntities
                Dim mSanctionList As New MSANCTIONLIST

                mSanctionList.LISTTYPECODE = txtListTypeCode.Text ' ชือลิสต์ความเสี่ยง 
                mSanctionList.LISTTYPENAME = txtListTypeName.Text ' รายละเอียด
                mSanctionList.FILENAME = txtFileName.Text.Trim & FileType ' ชื่อไฟล์ List
                'mSanctionList.BATCHJOB = PathFileFloderBatch & txtBatchJob.Text.Trim ' path ไฟล์Batch
                'mSanctionList.BATCHTESTJOB = PathFileFloderBatchTest & txtBatchJob.Text.Trim ' path ไฟล์Batch
                mSanctionList.BATCHJOB = txtBatchJob.Text.Trim ' path ไฟล์Batch
                mSanctionList.BATCHTESTJOB = txtBatchTestJob.Text.Trim ' path ไฟล์Batch
                mSanctionList.RISKLEVEL = txtRiskLevel.Text
                mSanctionList.FILETYPE = ddlList.SelectedValue.ToString
                SanctionEntity.AddToMSANCTIONLIST(mSanctionList)
                SanctionEntity.SaveChanges()

                SaveLog(3)
                IsDataBind()
                reset()

                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resMsgKYC.msgSave + "')", True)

            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + strMsg + "')", True)
            End If
        Catch ex As System.Data.UpdateException
            WriteError(ex, "btnAdd_Click", "mSanctionList")
            Dim codeError() As String = ex.InnerException.Message.Split(":")
            If codeError(0) = "ORA-00001" Then
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('ไม่สามารถเพิ่มได้ เนื่องจากรหัสนี้มีการนำมาใช้ในระบบแล้ว')", True)
            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + ex.InnerException.Message + "')", True)
            End If

        Catch ex As Exception
            WriteError(ex, "btnAdd_Click", "mSanctionList")
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('บันทึกผิดพลาด')", True)

        End Try
    End Sub

    Protected Sub btnModify_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnModify.Click
        'If Not (gvDepartment.SelectedIndex = -1) Then
        '    Response.Redirect("Department.aspx?Status=Edit&strDeptCode=" + gvDepartment.Rows(gvDepartment.SelectedIndex).Cells(1).Text)
        'Else
        '    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resValidate.nonSelectGrid + "')", True)
        'End If

     Try
            If chkBeforeSave() Then
                SanctionEntity = New SanctionEntities
                Dim mSanctionList As New MSANCTIONLIST

                Dim qry = (From Sanction In SanctionEntity.MSANCTIONLIST Where Sanction.LISTTYPECODE = txtListTypeCode.Text).ToList
                'txtPoscode.Text = qry(0).POSCODE
                qry(0).LISTTYPENAME = txtListTypeName.Text
                qry(0).FILENAME = txtFileName.Text.Trim & FileType ' ชื่อไฟล์ List
                qry(0).BATCHJOB = txtBatchJob.Text.Trim ' path ไฟล์Batch
                qry(0).BATCHTESTJOB = txtBatchTestJob.Text.Trim ' path ไฟล์Batch
                qry(0).RISKLEVEL = txtRiskLevel.Text
                qry(0).FILETYPE = ddlList.SelectedValue.ToString

                SanctionEntity.SaveChanges()
                SaveLog(4)
                IsDataBind()
                reset()

                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resMsgKYC.msgSave + "')", True)

            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + strMsg + "')", True)
            End If

        Catch ex As System.Data.UpdateException
            WriteError(ex, "btnModify_Click", "mSanctionList")
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + ex.InnerException.Message + "')", True)

        Catch ex As Exception
            WriteError(ex, "btnModify_Click", "mSanctionList")
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('บันทึกผิดพลาด')", True)

        End Try


    End Sub

    Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
       
        If Not (gvSanctionList.SelectedIndex = -1) Then
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "ConfirmDel()", True)
            ' Continue at hdfButton_Click method
        Else
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resValidate.nonSelectGridDelete + "')", True)

        End If

    End Sub

    Protected Sub hdfButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles hdfButton.Click
       
        Dim DepC As String = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(1).Text
        Dim fileType As String = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(2).Text
        Try
            Dim sanctionNewAll As New ADOEntitySanctionList.SanctionListEntities
            Dim chkInUseSanction = (From mImport In sanctionNewAll.AMLO_NEW_IMPORT_TEMP Where mImport.FILE_TYPE.ToLower.Equals(DepC.ToLower) Select mImport.FILE_TYPE).ToList
            If chkInUseSanction.Count > 0 Then
                Dim chkBridge = From ab In sanctionNewAll.AMLOCUSTOMERBRIDGEs
                             Group Join m In sanctionNewAll.AMLO_NEW_MASTER_TEMP
                             On ab.SANCTION_ID Equals m.ENTITY_ID Into grp1 = Group
                             From g1 In grp1.DefaultIfEmpty
                             Group Join im In sanctionNewAll.AMLO_NEW_IMPORT_TEMP On
                             im.IMPORTID Equals g1.IMPORTID Into grp2 = Group
                             From g2 In grp2.DefaultIfEmpty Where ab.APPROVE = 1 And g2.FILE_TYPE.Equals(DepC)
                             Select ab.CUSTOMER_ID

                If (chkBridge.Any) Then

                    ' can't delete
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('ไม่สามารถลบรายการนี้ได้เนื่องจากมีข้อมูล Sanction ที่เขื่อมโยงกับรายการนี้อยู่')", True)
                Else
                    ' can delete
                    SanctionEntity = New SanctionEntities
                    Dim qry = (From MSanction In SanctionEntity.MSANCTIONLIST Where MSanction.LISTTYPECODE = DepC).ToList
                    SanctionEntity.DeleteObject(qry(0))
                    SanctionEntity.SaveChanges()
                    SaveLog(5)
                    reset()
                    IsDataBind()
                End If

            Else
                ' can delete
                SanctionEntity = New SanctionEntities
                Dim qry = (From MSanction In SanctionEntity.MSANCTIONLIST Where MSanction.LISTTYPECODE = DepC).ToList
                SanctionEntity.DeleteObject(qry(0))
                SanctionEntity.SaveChanges()
                SaveLog(5)
                reset()
                IsDataBind()
            End If

        Catch ex As System.Data.UpdateException
            WriteError(ex, "btnDelete_Click", "mSanctionList")
            Dim codeError() As String = ex.InnerException.Message.Split(":")
            If codeError(0) = "ORA-02292" Then
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('ไม่สามารถลบได้ เนื่องจากมีการนำมาใช้ในระบบแล้ว')", True)
            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + ex.InnerException.Message + "')", True)
            End If

        Catch ex As Exception
            WriteError(ex, "btnDelete_Click", "mSanctionList")
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resError.errorMessage + "')", True)

        End Try
    End Sub

    Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click
        clear()
    End Sub

    Protected Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        '    Dim a As String = txtName.Text.Trim
        '    Dim param As String = "{ 'rptType' : '4'," _
        '                          & "'deptCode' : '" & txtListTypeCode.Text.Trim & "'," _
        '                          & "'deptName' : '" & a.ToString & "'}"
        '    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType, "key", "OpenWindowWithPost('../Form/frmPrintRptMaster.aspx','width=730,height=345,left=100,top=100,resizable=yes,scrollbars=yes','Report', " + param + ");", True)
    End Sub
#End Region


#Region "Even GridView"

    Protected Sub gvSanctionList_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvSanctionList.RowDataBound

    End Sub

    Protected Sub gvSanctionList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvSanctionList.SelectedIndexChanged
        If (gvSanctionList.SelectedIndex = intBeforeItemIndex) Then
            clearGvIndex()
            reset()

            btnModify.Text = "แก้ไข"
        Else
            btnModify.Text = "บันทึก"

            setButton(2)

            txtListTypeCode.Text = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(1).Text
            txtListTypeName.Text = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(4).Text
            txtRiskLevel.Text = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(3).Text
            txtFileName.Text = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(5).Text.Replace(".csv", "")
            txtBatchJob.Text = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(5).Text.Replace(PathFileFloderBatch, "")
            txtBatchTestJob.Text = gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(6).Text.Replace(PathFileFloderBatch, "")
            Dim LabelSanctionFileType = DirectCast(gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(7).FindControl("lbFileType"), Label)

            Dim listItems = ddlList.Items.FindByText(LabelSanctionFileType.Text)
            If (Not listItems Is Nothing) Then
                ddlList.ClearSelection()
                listItems.Selected = True
            Else
                ddlList.SelectedIndex = 0
            End If

            'btnDelete.Attributes.Add("onclick", "return confirm('" + String.Format(Resources.resValidate.confirmDelete, _
            '           IIf(gvSanctionList.SelectedIndex = -1, "", gvSanctionList.Rows(gvSanctionList.SelectedIndex).Cells(2).Text)) + "');")
        End If

    End Sub
    Protected Sub gvSanctionList_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles gvSanctionList.SelectedIndexChanging
        intBeforeItemIndex = gvSanctionList.SelectedIndex
    End Sub

    Protected Sub gvSanctionList_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvSanctionList.PageIndexChanging
        gvSanctionList.PageIndex = e.NewPageIndex
        clearGvIndex()
        DataBind()
    End Sub

    Protected Sub gvSanctionList_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles gvSanctionList.Sorting
        Dim dt = TryCast(dsSanction.Tables("sDepartment"), DataTable)

        If dt IsNot Nothing Then

            'Sort the data.
            dt.DefaultView.Sort = e.SortExpression & " " & GetSortDirection(e.SortExpression)
            gvSanctionList.DataSource = dsSanction.Tables("mSanctionList")
            gvSanctionList.DataBind()
            clearGvIndex()
        End If
    End Sub

#End Region


#Region " Function"

    Private Sub setUserRightButton()
        'Dim col As New Collection
        'col.Add(btnSearch, statusbtn.Query.ToString)
        'col.Add(btnAdd, statusbtn.Add.ToString)
        'col.Add(btnModify, statusbtn.Modify.ToString)
        'col.Add(btnDelete, statusbtn.delete.ToString)
        'col.Add(btnPrint, statusbtn.print.ToString)
        'setBtnToUserRight(col, strMenuCode, clsSessionMenuRight.getDsMenuRight)

    End Sub
    Private Sub clearGvIndex()
        gvSanctionList.SelectedIndex = -1
        '  btnDelete.Attributes.Clear()
    End Sub

    Private Sub IsDataBind()
        Try
            SanctionEntity = New SanctionEntities

            If dsSanction.Tables.Contains("mSanctionList") Then
                dsSanction.Tables.Clear()
            End If
            Dim qrySancation = From sanction In SanctionEntity.MSANCTIONLIST
                            Order By sanction.LISTTYPECODE
                        Select sanction.LISTTYPECODE, sanction.LISTTYPENAME, sanction.FILENAME, sanction.BATCHJOB, sanction.RISKLEVEL, sanction.BATCHTESTJOB, sanction.FILETYPE

            If Not (txtListTypeCode.Text = "") Then
                qrySancation = qrySancation.Where(Function(sanc) sanc.LISTTYPECODE.Contains(txtListTypeCode.Text))
            End If

            If Not (txtListTypeName.Text = "") Then
                qrySancation = qrySancation.Where(Function(sanc) sanc.LISTTYPENAME.Contains(txtListTypeName.Text))
            End If

            Try
                If (IsNumeric(txtRiskLevel.Text)) Then
                    'If Not (txtRiskLevel.Text = "") Then
                    qrySancation = qrySancation.Where(Function(sanc) sanc.RISKLEVEL = txtRiskLevel.Text)
                    'End If
                End If
            Catch ex As Exception
                Throw ex
            End Try


            If Not (txtFileName.Text = "") Then
                qrySancation = qrySancation.Where(Function(sanc) sanc.FILENAME.Contains(txtFileName.Text))
            End If
            If Not (txtBatchJob.Text = "") Then
                qrySancation = qrySancation.Where(Function(sanc) sanc.BATCHJOB.Contains(txtBatchJob.Text))
            End If
            If Not (txtBatchTestJob.Text = "") Then
                qrySancation = qrySancation.Where(Function(sanc) sanc.BATCHTESTJOB.Contains(txtBatchTestJob.Text))
            End If
            If Not (ddlList.SelectedIndex = 0) Then
                qrySancation = qrySancation.Where(Function(sanc) sanc.FILETYPE.Equals(ddlList.SelectedValue))
            End If

            dsSanction.Tables.Add(clsDataTable.LINQToDataTable(qrySancation, "mSanctionList").Copy)

            If (qrySancation.Count = 0) Then
                lblMsg.Visible = True
                lblTotal.Text = ""
            Else
                lblMsg.Visible = False
                lblTotal.Text = "จำนวนรายการทั้งหมด " + qrySancation.Count.ToString + " รายการ "

            End If

           
            gvSanctionList.DataSource = dsSanction.Tables("mSanctionList")
            gvSanctionList.DataBind()


            clsDataTable = Nothing
        Catch ex As Exception
            WriteError(ex, "IsDataBind", "mSanctionList")

        End Try


    End Sub



    Private Function GetSortDirection(ByVal column As String) As String

        ' By default, set the sort direction to ascending.
        Dim sortDirection = "DESC"

        ' Retrieve the last column that was sorted.
        Dim sortExpression = TryCast(ViewState("SortExpression"), String)

        If sortExpression IsNot Nothing Then
            ' Check if the same column is being sorted.
            ' Otherwise, the default value can be returned.
            If sortExpression = column Then
                Dim lastDirection = TryCast(ViewState("SortDirection"), String)
                If lastDirection IsNot Nothing _
                  AndAlso lastDirection = "DESC" Then

                    sortDirection = "ASC"

                End If
            End If
        End If

        ' Save new values in ViewState.
        ViewState("SortDirection") = sortDirection
        ViewState("SortExpression") = column
        Return sortDirection
    End Function

    Private Sub setButton(ByVal button As Integer)

        If button = 1 Then 'unselect
            lblMsg.Visible = False

            btnModify.Enabled = False
            btnDelete.Enabled = False

            btnSearch.Enabled = True
            btnAdd.Enabled = True

            txtListTypeCode.Enabled = True

        ElseIf button = 2 Then 'select

            btnSearch.Enabled = False
            btnAdd.Enabled = False

            btnModify.Enabled = True
            btnDelete.Enabled = True

            txtListTypeCode.Enabled = False

        End If

    End Sub

    Private Sub clear()
        If (dsSanction.Tables.Contains("mSanctionList")) Then
            dsSanction.Tables("mSanctionList").Clear()
            gvSanctionList.DataSource = dsSanction.Tables("mSanctionList")
            gvSanctionList.DataBind()
        End If
        clearGvIndex()
        setButton(1)
        lblMsg.Visible = False
        txtListTypeCode.Text = ""
        txtListTypeName.Text = ""
        txtFileName.Text = ""
        txtBatchJob.Text = ""
        txtBatchTestJob.Text = ""
        lblTotal.Text = ""
        btnModify.Text = "แก้ไข"
        txtRiskLevel.Text = ""
        ddlList.SelectedIndex = 0
    End Sub

    Private Sub reset()
        'gvUserRight.DataSource = dsUserRight.Tables("sUserRight")
        'gvUserRight.DataBind()
        clearGvIndex()
        setButton(1)
        lblMsg.Visible = False
        txtListTypeCode.Text = ""
        txtListTypeName.Text = ""
        txtFileName.Text = ""
        txtBatchJob.Text = ""
        txtBatchTestJob.Text = ""
        txtRiskLevel.Text = ""
        ddlList.SelectedIndex = 0
    End Sub

    Private Function chkBeforeSave() As Boolean
        Dim result As Boolean = True
        Dim strCharGroup As String = "['\""""@%#^!$&*.{},:;?/<>\[\]\\]"

        If (txtListTypeCode.Text = "") Then
            result = False
            strMsg = strMsg & "กรุณาระบุ" & lblListTypeCode.Text & "\n"
        Else
            If Regex.IsMatch(txtListTypeCode.Text, strCharGroup) Then
                result = False
                strMsg = strMsg & "ห้ามใส่อักขระพิเศษ" & "\n"
            End If
        End If


        If (txtListTypeName.Text = "") Then
            result = False
            strMsg = strMsg & "กรุณาระบุ" & lblListTypeName.Text & "\n"

        End If

        If (txtFileName.Text = "") Then
            result = False
            strMsg = strMsg & "กรุณาระบุ" & lblFileName.Text & "\n"

        End If

        'If (txtBatchJob.Text = "") Then
        '    result = False
        '    strMsg = strMsg & "กรุณาระบุ" & lblBatchJob.Text & "\n"

        'End If

        'If (txtBatchTestJob.Text = "") Then
        '    result = False
        '    strMsg = strMsg & "กรุณาระบุ" & lblBatchTestJob.Text & "\n"

        'End If

        If Not IsNumeric(txtRiskLevel.Text) Then
            result = False
            strMsg = strMsg & "กรุณาระบุ" & lblRiskLevel.Text & " " & "เป็นตัวเลข" & "\n"

        End If

        If ddlList.SelectedIndex = 0 Then
            result = False
            strMsg = strMsg & "กรุณาระบุ" & "ประเภทไฟล์" & "\n"
        Else
            If Not String.IsNullOrEmpty(txtListTypeCode.Text) AndAlso ddlList.SelectedIndex = 2 AndAlso (Not txtListTypeCode.Text.ToLower.Contains("eu") AndAlso Not txtListTypeCode.Text.ToLower.Contains("un") AndAlso Not txtListTypeCode.Text.ToLower.Contains("ofac")) Then
                result = False
                strMsg = strMsg & "กรุณาระบุ" & lblListTypeCode.Text & "ให้มีคำว่า UN,EU และ OFAC หากเลือกประเภทไฟล์เป็น XML" & "\n"
            End If

        End If

        Return result

    End Function

    Private Sub SaveLog(ByVal index As Integer)
        Try
            Dim program As String = "M71"
            Dim programName As String = " ข้อมูลหลัก > KYC > ข้อมูลลิสต์ความเสี่ยง"

            Dim desc As String = ""
            If index = 1 Then
                desc = "ค้นหา" + programName
            ElseIf index = 2 Then
                desc = "พิมพ์" + programName
            ElseIf index = 3 Then
                desc = "บันทึก" + programName + " (ชื่อลิสต์ความเสี่ยง " + txtListTypeCode.Text + ")"
            ElseIf index = 4 Then
                desc = "บันทึก แก้ไข" + programName + " (ชื่อลิสต์ความเสี่ยง " + txtListTypeCode.Text + ")"
            ElseIf index = 5 Then
                desc = "ลบ" + programName + " (ชื่อลิสต์ความเสี่ยง " + txtListTypeCode.Text + ")"
            End If

            Dim clsLogTransaction As New clsLogTransaction
            clsLogTransaction.saveLogTransaction(txtListTypeCode.Text.Trim, clsSessionMenuRight.getUserName, index, desc, program)


            clsLogTransaction = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

#End Region
   

End Class
